var commentpostpage=1;
function addformcredit()
{

   
   $(".wrpPlshArea .wrpPlsh").append('<div id="feature'+rowdiv+'" class="itPlg featureclass featurecreditcheck">'+dataform['credit']+"</div>");
   var rownow=rowdiv;


    var rowgnow=1;
  

  
   rowdiv++;
}
function savecoindata(productid)
{
loaddata();
$.post(serviceinfo+"savecoindata",{productid:productid},
function(data){




loadclosedata();
if(data.error.response)
{
if(data.error.error[0].code==5)
{
$('.ovlPopLd').hide();
$('.wrpPopLI').fadeIn();

//console.log('test');
}
else if(data.error.error[0].code==44)
{

$('#main-middle .checkcoin').fadeIn();
$('#main-middle .btnUseCoin').val('Buy Coins');
$('#main-middle .btnUseCoin').attr('onclick','linkto()');
$('#main-middle .btnUseCoin').attr('class','btnBuyCoin btnGen clTxtW cutTxt clBgBt1 fs04');


}
else
{
//alertbox(data.error.error);

alertbox(data.error.error);
}

}
else
{
var dataplugin={};
dataplugin['productid']=productid;
targetdiv='#main-middle';
getformcredit(dataplugin);


}











});



}
function getformcredit(dataplugin)
{
var code ='';

$.post(serviceinfo+"checkpostpurchase",{productid:dataplugin.productid},
function(data){

if(data.check)
{



if(data['plugins'].length)
{



$(''+targetdiv+' .wrpBodyLd.clBd2.bdBtm').html('');



$.each(data['plugins'], function(key, value) {
if(value.plugname!='credit')
{

eval("var rowdata=getform"+value.plugname+"(value)");
if(typeof rowdata != 'undefined'){



$(''+targetdiv+' .wrpBodyLd.clBd2.bdBtm').append(rowdata);
}

if(targetdiv=='#main-middle')
{



}


}



});


}





}else
{


code += '<div class="coinContent clBg4">\n';

code += '<div class="useCoin">\n';
code += '<h1 class="fs11">Use '+dataplugin.credit+' Coins to View</h1>\n';


code += '<p class="fs04 checkcoin" style="display:none" >Not Enough Coin</p>\n';


code += '<input type="button" onclick="savecoindata('+dataplugin.productid+')" value="Use Coins" class="btnUseCoin btnGen clTxtW cutTxt clBgSp2 fs04">\n';
code += '</div>\n';

//code += '<div class="useCoin">\n';
//code += '<h1 class="fs11">Use 10 Coins to View</h1>\n';
//code += '<p class="fs04">Not Enough Coin</p>\n';
//code += '<input type="submit" value="Buy Coins" class="btnBuyCoin btnGen clTxtW cutTxt clBgBt1 fs04">\n';
//code += '</div>\n';

code += '</div>';

}

});



return code;

}

function saveformcredit(id,plugid)
{
        var obj={};
        var credit=$('select[name="creditset"]').val();
        var iscredit=0;
        
        if($('input[name="iscredit"]:checked').val()=='1')
        {
        iscredit=1;
        
        }


        obj={plugid:plugid,iscredit:iscredit,credit:credit};
       
        return obj;
}
function editformcredit(datarow)
{
       addformcredit();
       
     
       
       
       $('input[name="iscredit"][value="'+iscredit+'"]').attr('checked',true);
       $('select[name="creditset"]').val(creditset);
       
       
  //     var status=$('input[name="commentstatus[]"][value="'+datarow['status']+'"]').attr('checked',true);
   //    var statuscomment=$('input[name="commentstatus2[]"][value="'+datarow['statuscomment']+'"]').attr('checked',true);
       
       var rownow= rowdiv-1;
       var rowgnow2=1;
       
       



}